

$(document).ready(function(){
  
   $('.themes').change(function() {
        var theme = "bootstrap-" + $(this).val();
        $.cookie("theme", theme, {path: '/'});
        setTheme("bootstrap-"+$(this).val())
        
    });   
    
    $('.sheading').change(function() {
            var val = $(this).val();
            var id = $(this).attr("id");
           $('#h-'+id).val(val);
     });
     
  $(".numericOnly").keydown(function(event) {
                   
                    if ( event.keyCode == 46 || event.keyCode == 8 || event.keyCode == 9 || event.keyCode == 27 || event.keyCode == 13 || 
                        // Allow: Ctrl+A
                    (event.keyCode == 65 && event.ctrlKey === true) || 
                        // Allow: home, end, left, right
                    (event.keyCode >= 35 && event.keyCode <= 39)) {
                        // let it happen, don't do anything
                        return;
                    }
                    else {
                        // Ensure that it is a number and stop the keypress
                        if (event.shiftKey || (event.keyCode < 48 || event.keyCode > 57) && (event.keyCode < 96 || event.keyCode > 105 )) {
                            event.preventDefault(); 
                        }   
                    }
        });

         loadTheme();
         
 });
 

 function setTheme(theme)
 {
    var local_theme = 'css/' +theme+'.min.css';
    $('head').append( $('<link rel="stylesheet" type="text/css" />').attr('href', local_theme) );
    $('head').append( $('<link rel="stylesheet" type="text/css" />').attr('href', 'css/bootstrap-responsive.min.css') );
 }
 
 function loadTheme()
 {
      if($.cookie("theme"))
       {   
           var c_theme = $.cookie("theme");
           setTheme(c_theme);
       }else
       {
            setTheme("bootstrap-default");
   }
 }